package com.yue.event;

import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * 功能描述: TODO <br/>
 * 创建时间: 2016/11/29<br/>
 *
 * @author QiuYang
 */
public abstract class ChangeListenerRegister<L extends ChangeListener> {

    private ConcurrentLinkedQueue<L> listenerQueue = new ConcurrentLinkedQueue<L>();

    public void register(L listener){
        listenerQueue.add(listener);
    }

    public void removeListener(L listener){
        listenerQueue.remove(listener);
    }

    public <E extends ChangeEvent> void fireEvent(E e){
        listenerQueue.forEach(l -> l.onEvent(e));
    }

}
